load("@fbsource//tools/build_defs:rust_library.bzl", "rust_library")

oncall("sapling")

rust_library(
    name = "revisionstore",
    srcs = glob(["src/**/*.rs"]),
    autocargo = {"cargo_toml_config": {
        "dependencies_override": {"dependencies": {
            "sapling-minibytes": {"features": ["frombytes"]},
            "sapling-version": {"path": "../version"},
        }},
        "features": {
            "default": [],
            "fb": [],
            "for-tests": [],
        },
        "lib": {"name": "revisionstore"},
        "package": {
            "authors": ["Meta Source Control Team <sourcecontrol-dev@meta.com>"],
            "homepage": "https://sapling-scm.com/",
            "license": "MIT",
            "name": "sapling-revisionstore",
            "repository": "https://github.com/facebook/sapling",
        },
    }},
    crate = "revisionstore",
    features = [
        "fb",
        "for-tests",
    ],
    test_deps = [
        "fbsource//third-party/rust:maplit",
        "fbsource//third-party/rust:mockito",
        "fbsource//third-party/rust:quickcheck",
        "fbsource//third-party/rust:rand_chacha",
        "fbsource//third-party/rust:tempfile",
    ],
    # A test inside this target is using #[should_panic], setting the backtrace
    # to false here, otherwise the test binary will try to extract the backtrace
    # and the test will fail with leak sanitizer.
    test_env = {"RUST_BACKTRACE": "0"},
    test_labels = ["tpx-rust-no-backtrace-workaround"],
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:async-trait",
        "fbsource//third-party/rust:byteorder",
        "fbsource//third-party/rust:flume",
        "fbsource//third-party/rust:fn-error-context",
        "fbsource//third-party/rust:fs-err",
        "fbsource//third-party/rust:futures",
        "fbsource//third-party/rust:http",
        "fbsource//third-party/rust:once_cell",
        "fbsource//third-party/rust:parking_lot",
        "fbsource//third-party/rust:paste",
        "fbsource//third-party/rust:quickcheck",
        "fbsource//third-party/rust:rand",
        "fbsource//third-party/rust:serde",
        "fbsource//third-party/rust:serde_derive",
        "fbsource//third-party/rust:serde_json",
        "fbsource//third-party/rust:sha1",
        "fbsource//third-party/rust:sha2",
        "fbsource//third-party/rust:thiserror",
        "fbsource//third-party/rust:tokio",
        "fbsource//third-party/rust:tokio-stream",
        "fbsource//third-party/rust:tracing",
        "fbsource//third-party/rust:url",
        ":revisionstore_types",
        "//common/rust/shed/quickcheck_arbitrary_derive:quickcheck_arbitrary_derive",
        "//eden/mononoke/lfs_protocol:lfs_protocol",
        "//eden/scm/lib/async-runtime:async-runtime",
        "//eden/scm/lib/blob:blob",
        "//eden/scm/lib/config/model:configmodel",
        "//eden/scm/lib/edenapi:edenapi",
        "//eden/scm/lib/edenapi/types:edenapi_types",
        "//eden/scm/lib/fsinfo:fsinfo",
        "//eden/scm/lib/hg-http:hg-http",
        "//eden/scm/lib/hg-metrics:hg-metrics",
        "//eden/scm/lib/hgtime:hgtime",
        "//eden/scm/lib/http-client:http-client",
        "//eden/scm/lib/indexedlog:indexedlog",
        "//eden/scm/lib/lz4-pyframe:lz4-pyframe",
        "//eden/scm/lib/manifest-augmented-tree:manifest-augmented-tree",
        "//eden/scm/lib/manifest-tree:manifest-tree",
        "//eden/scm/lib/metrics:metrics",
        "//eden/scm/lib/mincode:mincode",
        "//eden/scm/lib/minibytes:minibytes",
        "//eden/scm/lib/progress/model:progress-model",
        "//eden/scm/lib/repo/url:repourl",
        "//eden/scm/lib/storemodel:storemodel",
        "//eden/scm/lib/types:types",
        "//eden/scm/lib/util:util",
        "//eden/scm/lib/util/format-util:format-util",
        "//eden/scm/lib/util/redacted:redacted",
        "//eden/scm/lib/version:rust_version",
        "//eden/scm/lib/vlqencoding:vlqencoding",
    ],
)

rust_library(
    name = "revisionstore_types",
    srcs = glob(["types/**/*.rs"]),
    autocargo = {
        "cargo_toml_config": {
            "lib": {"name": "revisionstore_types"},
            "package": {
                "authors": ["Meta Source Control Team <sourcecontrol-dev@meta.com>"],
                "homepage": "https://sapling-scm.com/",
                "license": "MIT",
                "name": "sapling-revisionstore_types",
                "repository": "https://github.com/facebook/sapling",
            },
        },
        "cargo_toml_dir": "types",
    },
    crate_root = "types/lib.rs",
    features = [
        "for-tests",
    ],
    test_deps = [
        "fbsource//third-party/rust:quickcheck",
        "//common/rust/shed/quickcheck_arbitrary_derive:quickcheck_arbitrary_derive",
    ],
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:byteorder",
        "fbsource//third-party/rust:quickcheck",
        "fbsource//third-party/rust:serde",
        "fbsource//third-party/rust:serde_derive",
        "//common/rust/shed/quickcheck_arbitrary_derive:quickcheck_arbitrary_derive",
    ],
)
